<template>
	<view>
		<view v-for="(application, index) in applications" :key="index" class="list-item"
			@click="toDetail(application)">
			<view class="list-item-content1" style="height: 125rpx;">
				<view class="list-item-content-v">
					昵称：{{ application.name }}&nbsp;&nbsp;手机号：{{ application.phone }}
					<label v-if="application.applicationStatus === 0" class="status_fail">待审核</label>
					<label v-if="application.applicationStatus === 1" class="status_cussess">已通过</label>
					<label v-if="application.applicationStatus === 2" class="status_fail">未通过</label>
				</view>
				<view class="list-item-content-v">
					申请类型：{{ application.applicationType }}
				</view>
				<view class="list-item-content-v">
					申请时间：{{ application.applicationTime }}
				</view>
			</view>
		</view>

		<view style="width: 100%;height: 60rpx;float: left;"></view>
	</view>
</template>

<script setup>
	import CustomNavigationBar from '@/components/CustomNavigationBar.vue';
	import {
		ref
	} from "vue";
	import http from '../../utils/http';
	const applications = ref([])
	const modalVisible = ref(false);

	function showModal() {
		modalVisible.value = true;
	}

	function closeModal() {
		modalVisible.value = false;
	}
	const searchInitData = ref({});
	const searchDate = ref({});
	const status = ref([{
			id: 1,
			name: '状态1'
		},
		{
			id: 2,
			name: '状态2'
		}
	]);

	function selectStatus(item) {
		searchInitData.value.status = item.id;
		searchDate.value.status = item.id;
	}

	function search() {
		closeModal();
		console.log(searchDate.value)
	}

	function reset() {
		searchDate.value = {}
		console.log(searchDate.value)
	}

	function toDetail(application) {
		if(application.applicationType === 'shop'){
			uni.navigateTo({
				url: '/pages/approve/approve_detail_shop?application=' + encodeURIComponent(JSON.stringify(
					application)),
			});
		}else if(application.applicationType === 'cityPartner'){
			uni.navigateTo({
				url: '/pages/approve/approve_detail_citypartner?application=' + encodeURIComponent(JSON.stringify(
					application)),
			});
		}else if(application.applicationType === 'butler'){
			uni.navigateTo({
				url: '/pages/approve/approve_detail_butler?application=' + encodeURIComponent(JSON.stringify(
					application)),
			});
		}else if(application.applicationType === 'assistant'){
			uni.navigateTo({
				url: '/pages/approve/approve_detail_assistant?application=' + encodeURIComponent(JSON.stringify(
					application)),
			});
		}
		
		
	}

	function getAllApplicationByCityPartnerOpenid() {
		http.request({
			url: "/api/cityPartner/get_all_application",
			method: "POST",
			data: {
				"user": getApp().globalData.user
			}

		}).then((responseData) => {
			console.log("res", responseData.data)
			applications.value = responseData.data
			console.log(applications.value)
		})
	}
	onShow(() => {
		console.log("wadw", getApp().globalData.user)
		getAllApplicationByCityPartnerOpenid()
	})
</script>

<style>
	@import "./list.scss";
</style>